package com.ate.lib_core.http.factory

import com.ate.lib_core.http.product.HttpRetrofitNetworkImpl
import com.ate.lib_core.http.product.HttpRetrofitUploadImpl
import com.ate.lib_core.http.product.IRetrofitProduct

/**
 * @author Ate
 * @description:
 * @date :2020/12/9 11:16
 */
object RetrofitFactory : IRetrofitFactory {
    private var network:HttpRetrofitNetworkImpl? = null
    private var upload:HttpRetrofitUploadImpl? = null

    override fun createRetrofit(type: RetrofitType): IRetrofitProduct {
        return when (type){
            RetrofitType.NETWORK -> {
                if (network == null){
                    network = HttpRetrofitNetworkImpl()
                }
                network!!
            }
            RetrofitType.UPLOAD -> {
                if (upload == null){
                    upload = HttpRetrofitUploadImpl()
                }
                upload!!
            }
        }
    }

}